﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using TuyennvLibrary.Utl;
using TuyennvLibrary.ServerApi.Sms;

namespace ServerApi.Sms.PartnerSmsProccess
{
    public class FPTAdapter : PartnerSmsAdapter
    {
        String Telco;
        String Sentdate;
        public override object proccess(MsgObject mo, MsgContent msg, System.Web.HttpRequest request)
        {
            String Username, Password, Request_ID;
            //wtv userid: betv
            //ten userid: topteen

            Username = request["u"];
            Password = request["p"];
            //UserID = Request["PHONE"];
            Telco = request["TELCO"];
            Request_ID = request["MOID"];
            Sentdate = request["SENTDATE"];
            try
            {

                if (msg == null || msg.Count <= 0)
                    throw new Exception("Không có content");
                DateTime date = DateTime.Now;
                String time = date.Day + "" + date.Month + "" + date.Year;
                String mturl = "http://smsgateway.fptstore.com.vn/sendMT?ms.moid="
                    + Request_ID + "&ms.serviceNumber=" + mo.serviceid + "&&ms.syntax="
                    + HttpUtility.UrlEncode(mo.command_code) + "&ms.dateSend=" + time + "&ms.telco="
                    + Telco + "&ms.message=" + HttpUtility.UrlEncode(msg[0].content) + "&ms.phone="
                    + msg[0].userid + "&username=bluesea&password=" + ("bluesea@2013");
                String mtresponse = Utilities.Request(mturl);
                return mtresponse;
            }
            catch (Exception ex)
            {
                return ex.Message;
            }

        }
    }
}
